package com.cuitrip.business.order.detail.ui.viewholder;

import android.view.View;

import com.cuitrip.app.base.PartViewHolder;
import com.cuitrip.business.order.detail.ui.model.OrderInfoPartRenderData;
import com.cuitrip.component.item.ItemLayout;
import com.cuitrip.service.R;
import com.cuitrip.util.text.TextProxy;
import com.cuitrip.util.time.InputTime;
import com.cuitrip.util.time.OutputTime;
import com.cuitrip.util.time.TimeUtil;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 订单信息行程viewholder
 * Created by ak
 */
public class OrderInfoPartViewHolder implements PartViewHolder<OrderInfoPartRenderData> {

    @Bind(R.id.date_layout)
    ItemLayout mDateLayout;


    @Bind(R.id.traveller_layout)
    ItemLayout mTravellerLayout;

    @Bind(R.id.duration_layout)
    ItemLayout mDurationLayout;

    public void build(View view) {
        ButterKnife.bind(this, view);
    }

    public void render(final OrderInfoPartRenderData data) {
        String timeFormat = TimeUtil.formatTime(
                InputTime.build(data.getOrderServiceDate(), TimeUtil.getZeroZone()),
                OutputTime.getInstance(OutputTime.OutputType.Type_DAY, TimeUtil.getZeroZone()));
        mDateLayout.setmRightText(timeFormat);
        String personNum = TextProxy.getInstance().formatWithSingleAndMore(data.getOrderServicePersonNumber(), R.string.trip_attribute_capacity_value_one, R.string.trip_attribute_capacity_value_more);
        mTravellerLayout.setmRightText(personNum);
        String duration = TextProxy.getInstance().formatWithSingleAndMore(data.getOrderServiceDuration(), R.string.trip_attribute_duration_value_one, R.string.trip_attribute_duration_value_more);
        mDurationLayout.setmRightText(duration);
    }


}
